using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;namespace DemandVideo1{ public partial class Index : Form { private String url = @"D:\\CSharp代码(未整理)\\S1作业\\KTV项目-自己\\KTV\\资源\\song\\"; //绝对路径 private OpenFileDialog openFile = new OpenFileDialog(); private Dictionary<int, String> d = new Dictionary<int, string>(); private String activeUrl = ""; public Index() { InitializeComponent(); initList(); } private void wmp_Enter(object sender, EventArgs e) { this.listPan.Visible = false; } private void Index_Load(object sender, EventArgs e) { } //打开文件按钮 private void clickBtn_Click(object sender, EventArgs e) { openFile.ShowDialog(); this.picPan.Visible = false; this.wmp.URL = openFile.FileName; activeUrl = openFile.FileName; this.Text = "点播视频 " openFile.FileName.Split('.')[0]; this.playBtn.Text = "暂停"; } //播放、暂停按钮 private void playBtn_Click(object sender, EventArgs e) { //this.wmp.URL = openFile.FileName; Button btn = (Button)sender; if (btn.Text.Equals("播放")) { this.wmp.URL = activeUrl; btn.Text = "停止"; this.picPan.Visible = false; } else { this.wmp.close(); this.picPan.Visible = true; this.listPan.Visible = false; btn.Text = "播放"; } } //文件列表按钮 private void listBtn_Click(object sender, EventArgs e) { this.listPan.Visible = !this.listPan.Visible; //System.Windows.Forms.Button btn1 = new System.Windows.Forms.Button(); /*this.closeBtn.Location = new System.Drawing.Point(693, 457); this.closeBtn.Name = "closeBtn"; this.closeBtn.Size = new System.Drawing.Size(75, 23); this.closeBtn.TabIndex = 3; this.closeBtn.Text = "停止"; this.closeBtn.UseVisualStyleBackColor = true; this.closeBtn.Click = new System.EventHandler(this.closeBtn_Click);*/ } private void initList() { /*for (int i = 0; i < 35; i ) { Button label = new Button(); label.Location = new System.Drawing.Point(0, 23 * i); label.Size = new System.Drawing.Size(75, 23); label.BackColor = System.Drawing.Color.Blue; label.Text = "kkkkkkkk" i; //label.TabIndex = 10 i; label.Click = new System.EventHandler(this.label_Click); this.listPan.Controls.Add(label); }*/ this.listPan.AutoScroll = true; //禁止窗体放大缩小 this.MinimizeBox = true; this.MaximizeBox = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; //this.listPan.MouseLeave = new System.EventHandler(this.listPan_MouseLeave); //this.picPan.MouseMove = new System.EventHandler(this.wmp_Enter); DirectoryInfo di = new DirectoryInfo(url); int i = 0; try { foreach (FileInfo f in di.GetFiles()) { Label label = new Label(); label.Location = new System.Drawing.Point(10, 23 * i 10); label.Size = new System.Drawing.Size(75, 23); label.BackColor = System.Drawing.Color.Blue; label.ForeColor = System.Drawing.Color.White; label.Text = f.Name; //label.TabIndex = 10 i; label.Click = new System.EventHandler(this.label_Click); this.listPan.Controls.Add(label); } } catch (Exception ex) { } } private void label_Click(object sender, EventArgs e) { //this.closeBtn.Text = ((Label)this.Controls["label"]).Text; //this.closeBtn.Text = ((Button)sender).Text; activeUrl = url ((Label)sender).Text; this.wmp.URL = url ((Label)sender).Text; this.playBtn.Text = "暂停"; this.Text = "点播视频 " ((Label)sender).Text.Split('.')[0]; this.picPan.Visible = false; } /* URL:String; 指定媒体位置,本机或网络地址 uiMode:String; 播放器界面模式,可为Full, Mini, None, Invisible playState:integer; 播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪 enableContextMenu:Boolean; 启用/禁用右键菜单 fullScreen:boolean; 是否全屏显示 [controls] wmp.controls //播放器基本控制 controls.play; 播放 controls.pause; 暂停 controls.stop; 停止 controls.currentPosition:double; 当前进度 controls.currentPositionString:string; 当前进度,字符串格式。如“00:23” controls.fastForward; 快进 controls.fastReverse; 快退 controls.next; 下一曲 controls.previous; 上一曲 [settings] wmp.settings //播放器基本设置 settings.volume:integer; 音量,0-100 settings.autoStart:Boolean; 是否自动播放 settings.mute:Boolean; 是否静音 settings.playCount:integer; 播放次数 [currentMedia] wmp.currentMedia //当前媒体属性 currentMedia.duration:double; 媒体总长度 currentMedia.durationString:string; 媒体总长度,字符串格式。如“03:24” currentMedia.getItemInfo(const string); 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述,"Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址 currentMedia.setItemInfo(const string); 通过属性名设置媒体信息 currentMedia.name:string; 同 currentMedia.getItemInfo("Title") [currentPlaylist] wmp.currentPlaylist //当前播放列表属性 currentPlaylist.count:integer; 当前播放列表所包含媒体数 currentPlaylist.Item[integer]; 获取或设置指定项目媒体信息,其子属性同wmp.currentMedia */ }}
下载winform 播放本地视频源码下载(Interop.WMPLib)用户还喜欢
- 18480 文章数
- 500万+ 热度
作者专栏
编辑推荐
- 淡抹u2引擎,修复内容较多,物有所值
- 界域传说·经典巨作=传世单机(一键安装)
- 丸子版本(175个传世版本大集合)
- GS版本:神话公益服务端+客户端
- 图片放大工具(放大图片不模糊)
- 剪映无限制VIP版
- 传奇世界客户端下载器,史上最全传世客户端
- 传世GS20220920商业引擎注册+登录配置器 解压密码是1
- U2官方排行榜游戏网关 支持元神,支持传家宝
- GS开战传世客户端+服务端
- (淡漠夕阳)u2引擎合区工具
- 传世GS引擎消除“你的游戏客户端版本号过旧,请及时更新”提示
- 传世一机多区双线路配置器--免密码版本
- 传世凤凰登陆器劫持修复软件
- SQLite3 for Navicat
- 传奇世界npc对话框编辑工具
- 传世GS落霞铭文服务器端
- gs_20210409引擎包+注册机(无限制)
- 传奇世界NPC对话封包查看器[支持时长版和极速版]
- 彩虹引擎传世脚本编辑工具1.7版来了,支持函数脚本翻译
评论